<!DOCTYPE html>
<html>
<head>
  <script src="../../processing.js"></script>
  <script src="../init.js"></script>
<link rel="stylesheet" href="../style.css"/></head>
<body><h1><a href="http://ejohn.org/blog/processingjs/">Processing.js</a></h1>
<h2>Alphamask</h2>

<p>This code was updated from the Java source to work with Processing.js asynchronous image loading. Not sure image masks were ever implemented in Processing.js.<sup>-F1LT3R</sup></p> 


<p>Loads a "mask" for an image to specify the transparency 
in different parts of the image. The two images are blended
together using the mask() method of PImage. 

Created 29 April 2003.</p>

<p><a href="http://processing.org/learning/basics/alphamask.html"><b>Original Processing.org Example:</b> Alphamask</a><br>
<script type="application/processing">
PImage img;
PImage maskImg;

void setup() 
{
  size(200,200);
  img = loadImage("data/test.jpg");
  maskImg = loadImage("data/mask.jpg");
  img.mask(maskImg);
}

void draw() 
{
  background((mouseX+mouseY)/1.5);
  image(img, 50, 50);
  image(img, mouseX-50, mouseY-50);
}
</script><canvas width="200" height="200"></canvas></p>
<div style="height:0px;width:0px;overflow:hidden;"><img src='data/mask.jpg' id='mask.jpg'/><img src='data/test.jpg' id='test.jpg'/></div>

<pre><b>// All Examples Written by <a href="http://reas.com/">Casey Reas</a> and <a href="http://benfry.com/">Ben Fry</a>
// unless otherwise stated.</b>
PImage img;
PImage maskImg;

void setup() 
{
  size(200,200);
  img = loadImage("test.jpg");
  maskImg = loadImage("mask.jpg");
  img.mask(maskImg);
}

void draw() 
{
  background((mouseX+mouseY)/1.5);
  image(img, 50, 50);
  image(img, mouseX-50, mouseY-50);
}</pre>
</body>
</html>
